package com.example.mr5.mygame.utils;/**
 * Created by Mr.5
 * Date：2016/5/15.
 * Time：23:15
 */

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;

/**
 * Created by Mr.5
 * Date：2016/5/15.
 * Time：23:15
 */
public class NetWorkConnection {
    private Context context;

    public NetWorkConnection(Context context){
        this.context = context;
    }

    public boolean isConnection() {

        ConnectivityManager con = (ConnectivityManager) context.getSystemService(Activity.CONNECTIVITY_SERVICE);
        boolean wifi = con.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();
        boolean internet = con.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnectedOrConnecting();
        if (wifi | internet) {
            return true;
        } else return false;
    }
}
